#include <stdio.h>
#include <stdlib.h>
#include "mysql.h"
#define TIP "127.0.0.1"
#include "TUser.h"
#include "TUserDal.h"

int main()
{


	//test paraquery
	TUser * list[1024] = {0}; // 最多1024个地址，每个地址都指向一个堆空间

	TUser_paraquery2(&list); // ref list



	int i = 0;
	while(1)
	{
		if(list[i] == NULL)
		{
			break;
		}
		printf("%s - %s - %s - %d\n", list[i]->TU_Guid, list[i]->TU_UserName, list[i]->TU_Password, list[i]->TU_Age);

		// 用完马上delete
		if(list[i] != NULL)
		{
			free(list[i]);
			list[i] = NULL;
		}
		i++;
	}

    /*zvector * vs = NULL;
    zvector_create(&vs, 0);
    TUser_paraquery3(vs);
    printf("len = %d\n", vs->m_Length);
    int t_i = 0;
    for(t_i = 0; t_i < vs->m_Length; t_i++)
    {
        printf("%d index guid is %s\n", ((TUser *)vs->m_List[t_i])->TU_Guid);
    }
    zvector_destroy(&vs);*/

	TUser * f = NULL;
	TUser_GetFirstOrDefaultByTU_UserName("zjr11111", &f);
	if(f)
	{
		printf("%s -- %s -- %s -- %d\n", f->TU_Guid, f->TU_UserName, f->TU_Password, f->TU_Age);
		free(f);
		f = NULL;
	}
	else
	{
		printf("f is null");
	}

	TUser user;
	strcpy(user.TU_UserName, "zjrwd");
	strcpy(user.TU_Password, "haha");
	user.TU_Age = 18;
	printf("will add\n");
	TUser_Add(&user);
	printf("add finish\n");

	printf("ok\n");
	return 0;
}


